using System;
using System.Collections;
using System.Text;
using Sedna.Core.Controller;
using Sedna.Core.Controller.Common;
using Sedna.UI.Test.Wrappers;
using Sedna.Util;

namespace Sedna.UI.Test.Actions
{
    public class TestApplyAction: AbstractAction
    {
        private string parameterPath;
        private string applyCollectionPath;
        
        public string ParameterPath
        {
            get { return parameterPath;}
            set { parameterPath = value;}
        }
        
        public string ApplyCollectionPath
        {
            get { return applyCollectionPath;}
            set { applyCollectionPath = value;}
        }
        
        public override IActionResult Execute(IExecutionContext executionContext)
        {
            string value = executionContext.GetPropertyValue(parameterPath) as string;

            IList list = new ArrayList();
            
            for (int i = 1; i <= 10; i++)
            {
                list.Add(new TestWrapper(i, value));
            }
            
            CollectionProvider provider = new CollectionProvider(list);
            executionContext.SetPropertyValue(applyCollectionPath, provider);            
            
            return CreateResult("step2");
        }
    }
}
